package com.ylb.rent.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ylb.rent.config.PageConfig;
import com.ylb.rent.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;

import com.ruoyi.common.enums.BusinessType;
import com.ylb.rent.entity.Forbid;
import com.ylb.rent.service.IForbidService;


/**
 * 禁止事项Controller
 * 
 * @author ruoyi
 * @date 2023-07-02
 */
@RestController
@RequestMapping("/forbid/forbid")
@Slf4j
public class ForbidController
{
    @Autowired
    private IForbidService forbidService;

    /**
     * 查询禁止事项列表
     */
    @PreAuthorize("@ss.hasPermi('forbid:forbid:list')")
    @GetMapping("/list")
    public String list(Forbid forbid, PageConfig pageConfig)
    {
        PageHelper.startPage(pageConfig);
        List<Forbid> list = forbidService.selectForbidList(forbid);
        log.error("forbid : "+forbid);
        return R.successJSONData(new PageInfo<>(list));
       
    }

   

    /**
     * 获取禁止事项详细信息
     */
    @PreAuthorize("@ss.hasPermi('forbid:forbid:query')")
    @GetMapping(value = "/{id}")
    public String getInfo(@PathVariable("id") Long id)
    {
        return R.successJSONData(forbidService.selectForbidById(id));
    }

    /**
     * 新增禁止事项
     */
    @PreAuthorize("@ss.hasPermi('forbid:forbid:add')")
    @Log(title = "禁止事项", businessType = BusinessType.INSERT)
    @PostMapping
    public String add(@RequestBody Forbid forbid)
    {
        return R.successJSONData(forbidService.insertForbid(forbid));
    }

    /**
     * 修改禁止事项
     */
    @PreAuthorize("@ss.hasPermi('forbid:forbid:edit')")
    @Log(title = "禁止事项", businessType = BusinessType.UPDATE)
    @PutMapping
    public String edit(@RequestBody Forbid forbid)
    {
        return R.successJSONData(forbidService.updateForbid(forbid));
    }

    /**
     * 删除禁止事项
     */
    @PreAuthorize("@ss.hasPermi('forbid:forbid:remove')")
    @Log(title = "禁止事项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public String remove(@PathVariable Long[] ids)
    {
        return R.successJSONData(forbidService.deleteForbidByIds(ids));
    }
}
